package com.totoro.dubbo;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ConsumerConfig;
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.totoro.dubbo.properties.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

/**
 * Created by Niki on 2018/7/3 8:52
 */
@ComponentScan
public class DubboConfig {

    @Bean
    public ApplicationConfig applicationConfig(ApplicationConfigProperties properties) {
        ApplicationConfig applicationConfig = new ApplicationConfig();
        Properties2Config.properties2Config(properties, applicationConfig);
        return applicationConfig;
    }

    @Bean
    public RegistryConfig registryConfig(RegistryConfigProperties properties) {
        RegistryConfig registryConfig = new RegistryConfig();
        Properties2Config.properties2Config(properties, registryConfig);
        return registryConfig;
    }

    @Bean
    public ProtocolConfig protocolConfig(ProtocolConfigProperties properties) {
        ProtocolConfig protocolConfig = new ProtocolConfig();
        Properties2Config.properties2Config(properties, protocolConfig);
        return protocolConfig;
    }

    @Bean
    public ConsumerConfig consumerConfig(ConsumerConfigProperties properties) {
        ConsumerConfig consumerConfig = new ConsumerConfig();
        Properties2Config.properties2Config(properties, consumerConfig);
        return consumerConfig;
    }

}
